//
//  BaseTabBarController.m
//  FlyGift
//
//  Created by lanou3g on 15/7/11.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "BaseTabBarController.h"

@interface BaseTabBarController ()

@end

@implementation BaseTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabBar.tintColor = KColor(229, 56, 50, 1.0);
    self.tabBar.translucent = NO;
    
    MainClassViewController * mainClassVC = [[MainClassViewController alloc]init];
    SortsOfGiftViewController * sortsVC = [[SortsOfGiftViewController alloc]init];
    SingleProductViewController * singleVC = [[SingleProductViewController alloc]init];
    RecommendTableViewController * recommendTVC = [[RecommendTableViewController alloc]init];
    UINavigationController * mainClassNav = [[UINavigationController alloc]initWithRootViewController:mainClassVC];
    UINavigationController * sortsNav = [[UINavigationController alloc]initWithRootViewController:sortsVC];
    UINavigationController * singleNav = [[UINavigationController alloc]initWithRootViewController:singleVC];
    UINavigationController * recommendNav = [[UINavigationController alloc]initWithRootViewController:recommendTVC];

    [self addChildViewController:mainClassVC image:@"bottom_home_icon@2x" title:@"飞礼"];
    [self addChildViewController:sortsVC image:@"sorts@2x" title:@"分类"];
    [self addChildViewController:singleVC image:@"single@2x" title:@"热卖"];
    [self addChildViewController:recommendTVC image:@"recommend@2x" title:@"推荐"];
    self.viewControllers = @[mainClassNav,sortsNav,singleNav,recommendNav];
    
    mainClassVC.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"iconTabMyAccountViewController_iPadFocus_iPad@2x"] style:UIBarButtonItemStylePlain target:self action:@selector(leftBarButtonAction:)];
    mainClassVC.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"AGShareSettingIcon@2x"] style:UIBarButtonItemStylePlain target:self action:@selector(rightBarButtonAction:)];
}

#pragma mark --- 添加子视图控制器的方法
-(void)addChildViewController:(UIViewController *)childController image:(NSString *)imageName title:(NSString *)title
{
    childController.tabBarItem.image = [UIImage imageNamed:imageName];
    childController.tabBarItem.title = title;
    childController.navigationItem.title = title;
    childController.navigationController.navigationBar.barTintColor = KColor(255, 140, 179, 1.0);
}  

#pragma mark --- 抽屉按钮点击事件
-(void)leftBarButtonAction:(UIBarButtonItem *)barButton
{
    [self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];
}
-(void)rightBarButtonAction:(UIBarButtonItem *)barButton
{
    [self.mm_drawerController toggleDrawerSide:MMDrawerSideRight animated:YES completion:nil];
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


@end
